/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.suspend.local;

import android.content.ComponentName;
import android.content.Context;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
import com.qihoo.gamecenter.sdk.suspend.b.b;
import com.qihoo.gamecenter.sdk.suspend.remote.IQRemoteService;
import com.qihoo.gamecenter.sdk.suspend.remote.IQRemoteService.a;

public class a implements ServiceConnection {
    private static Context a = null;
    private static IQRemoteService b = null;
    private static boolean c = false;

    public a(Context paramContext) {
        a = paramContext;
        c = false;
    }

    public void onServiceConnected(ComponentName paramComponentName, IBinder paramIBinder) {
        try {
            b = IQRemoteService.a.a(paramIBinder);
            c = true;
            String str = a.getPackageName();
            boolean bool = b.isPrimary(str);
            b.a("QLocalSession", "packName: " + str + ", bPrimary: " + bool);
            b();
        } catch (Exception localException) {
            b.a("QLocalSession", localException);
        }
    }

    private void b() {
        QLocalService.a = com.qihoo.gamecenter.sdk.suspend.c.a.e(a.getApplicationContext());
        if (TextUtils.isEmpty(QLocalService.a))
            return;
        String[] arrayOfString = QLocalService.a.split(":");
        String str1 = "";
        for (int i = 0; i < arrayOfString.length; ++i) {
            str1 = arrayOfString[i];
            if ((TextUtils.isEmpty(str1)) || (b == null))
                continue;
            b.a("QLocalSession", "-----------------------------------------------");
            String str2 = com.qihoo.gamecenter.sdk.suspend.c.a.e(a, str1);
            String str3 = com.qihoo.gamecenter.sdk.suspend.c.a.d(a, str1);
            b.a("QLocalSession", "  \nmQid : " + str2 + "  \nmQt : " + str3 + "  \nLoginedPkgname " + str1);
            try {
                b.updateLoginedState(str1, str2, str3);
            } catch (RemoteException localRemoteException) {
                localRemoteException.printStackTrace();
            } catch (Throwable localThrowable) {
                localThrowable.printStackTrace();
            }
        }
    }

    public static IQRemoteService a() {
        return b;
    }

    public void onServiceDisconnected(ComponentName paramComponentName) {
        try {
            a.unbindService(this);
            c = false;
            b = null;
            QLocalService.a(a);
        } catch (Exception localException) {
            b.a("QLocalSession", localException);
        }
    }
}